import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/login/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/test',
      name: 'test',
      component: () => import('../views/test/index.vue')
    },
    {
      path: '/myslots',
      name: 'myslots',
      component: () => import('../views/mySlots/index.vue')
    }
  ]
})

// 导航守卫
router.beforeEach((to, from, next) => {
  // to:即将进入的目标
  // from: 当前导航正要离开的路由
  // return false // 返回false用于取消导航
  // return {name:'text'} // 返回到对应的test页面
  // next({name:'text'}) //进入到对应的页面
  next() // 放行
})

export default router
